package com.leyou.item.mapper;

import com.leyou.item.pojo.Stock;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

public interface StockMapper extends Mapper<Stock> {

    //库存递减， 返回受影响的行数@
    //需要完全命中索引
    @Update("update tb_stock set stock = stock - #{decrNum} where sku_id = #{skuId} and stock > #{decrNum}")
    int decreCount(@Param(value = "skuId") Long skuId, @Param(value = "decrNum") Integer decrNum);
}
